<?php

class customer_model extends CI_Model {

    function __construct()
    {
        parent::__construct();
        
    }
    function get($Mail){
//        $vlows=array("'","\\","#");
//        $Mail=  str_replace($vlows, "", $Mail);
//        $query = $this->db->query("
//            SELECT `dtb_customer`.*
//            FROM `dtb_customer`
//            WHERE `dtb_customer`.`delete` is null 
//                AND `dtb_customer`.`Mail`='$Mail'                
//        ");
        $where=array("Mail"=>$Mail);
        $query=$this->db->get_where("dtb_customer",$where);
        return $query->result();
    }
    function getMail($Mail){
        $where=array("Email"=>$Mail);
        $query=$this->db->get_where("dtb_mail",$where);
        return $query->result();
    }
    function insert($params){
        $this->db->set('Insert', 'NOW()', FALSE);
        $this->db->insert('dtb_customer', $params); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1){ 
            return true;
        }
        return false;
    }
    function insertMail($params){
        $this->db->set('Insert', 'NOW()', FALSE);
        $this->db->insert('dtb_mail', $params); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1){ 
            return true;
        }
        return false;
    }
    function update($id,$params){
        $this->db->where('CustomerID', $id);
        $this->db->set('Update', 'NOW()', FALSE);
        $this->db->update('dtb_customer', $params); 
        $count = $this->db->affected_rows(); //should return the number of rows affected by the last query
        if($count==1) return true;
        return false;
    }
    
}
?>
